package com.wc.alorithm_blue_bridge._思维.子2023;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/7/23 15:46
 * @description https://www.lanqiao.cn/problems/17104/learning/?page=1&first_category_id=1
 */
public class Main {
    /**
     * 思路：
     * 贡献, 只有 2 0 2 3 有贡献
     * 2 分为两种, 一个是第一个 2 , 一个是第二个 2
     * 2: 计数, 2的个数
     * 0: 计数, 前面有多少个2
     * 2: 计数, 前面有多少个0
     * 3: 计数, 前面有多少个第二个2
     */
    static PrintWriter out = new PrintWriter(System.out);
    static int n;

    public static void main(String[] args) {
        n = 2023;
//        n = 23;
        StringBuilder ss = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            ss.append(i);
        }
        char[] cs = ss.toString().toCharArray();
        int two = 0, zero = 0, two2 = 0, three = 0;
        long res = 0;
        for (char c : cs) {
            if (c == '2') {
                two2 += zero;
                two++;
            }
            if (c == '0') {
                zero += two;
            }
            if (c == '3') {
                res += two2;
            }
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
